import request from '@/utils/request'
const moduleApi = '/goods'

/**
 * 套餐信息
 * @param {Object} params
 * @returns
 */
export function getComboList(query) {
  return request({
    url: moduleApi + '/combo',
    method: 'get',
    params: query
  })
}

/**
 * 新增套餐
 * @param {Object} params
 * @returns
 */
export function addCombo(data) {
  return request({
    url: moduleApi + '/combo',
    headers: { repeatSubmit: false },
    method: 'post',
    data
  })
}

/**
 * 套餐商品列表
 * @param {String} comboId
 * @returns
 */
export function getComboGoodsLine(comboId) {
  return request({
    url: moduleApi + `/comboGoods/${comboId}`,
    method: 'get'
  })
}

/**
 * 新增套餐商品行
 * @param {Object} data
 * @returns
 */
export function addComboGoodsLine(data) {
  return request({
    url: moduleApi + '/comboGoods',
    headers: { repeatSubmit: false },
    method: 'post',
    data
  })
}

/**
 * 删除套餐商品行
 * @param {String} comboGoodsId
 * @returns
 */
export function delComboGoodsLine(comboGoodsId) {
  return request({
    url: moduleApi + `/comboGoods/${comboGoodsId}`,
    method: 'put'
  })
}

/**
 * 修改套餐
 * @param {Object} data
 * @returns
 */
export function updateCombo(data) {
  return request({
    url: moduleApi + '/combo',
    headers: { repeatSubmit: false },
    method: 'put',
    data
  })
}

/**
 * 套餐详情
 * @param {String} id
 * @returns
 */
export function getComboDetail(id) {
  return request({
    url: moduleApi + `/combo/${id}`,
    method: 'get'
  })
}

/**
 * 套餐详情图片
 * @param {String} id
 * @returns
 */
export function getComboImgDetail(id) {
  return request({
    url: moduleApi + `/comboDetailImg/${id}`,
    method: 'get'
  })
}

/**
 * 套餐参与的计划列表
 * @param {String} comboId
 * @returns
 */
export function getComboPlanList(comboId) {
  return request({
    url: moduleApi + `/combo/plan/${comboId}`,
    method: 'get'
  })
}

/**
 * 套餐 上/下架
 * @param {String} id
 * @returns
 */
export function shelfCombo(id) {
  return request({
    url: moduleApi + `/combo/shelf/${id}`,
    method: 'get'
  })
}

/**
 * 上下架团餐
 * @param {String} comboId
 * @returns
 */
export function groupCombo(comboId) {
  return request({
    url: moduleApi + `/combo/groupShelf/${comboId}`,
    method: 'get'
  })
}
